<?php

namespace app\teacher\controller\core;

use app\common\controller\Frontend;
use app\common\model\banxi\core\CoreMyLexicon as CoreMyLexiconModel;
use think\facade\Log;

/*
 * 阅读理解
 * */
class CoreMyLexicon extends Frontend
{
    protected array $noNeedLogin = [''];

    protected array $noNeedPermission = ['*'];

    public function initialize(): void
    {
        parent::initialize();
    }

    /*
     * 查询-阅读记录信息
     * */
    public function listMyCollect()
    {

        $user = $this->auth->getUserInfo();
        $CoreMyLexiconModel = new CoreMyLexiconModel();
        $list = $CoreMyLexiconModel
            ->with(['lexiconInfo'])
            ->where(['accountId'=>$user['id'],'accountType'=>4,'isCollect'=>1])
            ->order('updateTime','desc')
            ->select();
        $this->ok('操作成功',$list);
    }

    /*
     * 收藏-取消收藏
     * */
    public function updateCollect()
    {
        $word = $this->request->post('word','');
        if(!$word){
            $this->error('请选择单词');
        }
        $user = $this->auth->getUserInfo();
        $CoreMyLexiconModel = new CoreMyLexiconModel();
        $res = $CoreMyLexiconModel->updateCollect($user['id'],4,0,$word);

        $this->ok('操作成功');
    }

}